package com.smh.aiagent.rag;

import jakarta.annotation.Resource;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.ai.document.Document;
import org.springframework.ai.transformer.KeywordMetadataEnricher;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author shiminghui
 * @date 2025/6/3 16:12
 * @description: TODO
 */
@Component
public class LoveEnrichMetadata {

    @Resource
    private ChatModel dashscopeChatModel;

    public List<Document> enrichMetadata(Integer keywordCount, List<Document> documents) {

        KeywordMetadataEnricher enricher = new KeywordMetadataEnricher(dashscopeChatModel, keywordCount);
        // 内部其实就是调用AI,让AI来提取关键词
        return enricher.apply(documents);
    }

}
